<?php
namespace core\lib;
use \core\lib\conf;
class route{
	public $ctrl;
	public $action;
	public function __construct()
	{
		// xxx.com/index.php/index/index
		/**
		 * 隐藏php
		 * 获取URL参数
		 * 返还对应控制器的参数
		*/
		if(isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != '/'){
			$path = $_SERVER['PATH_INFO'];
			$patharr = explode('/',trim($path,'/'));
			if(isset($patharr[0])){
				$this->ctrl = $patharr[0];
			}
			unset($patharr[0]);
			if(isset($patharr[1])){
				$this->action = $patharr[1];
				unset($patharr[1]);
			}else{
				$this->action = C('ACTION');
			}
			// url多余部分 get参数 index/index/id/1
			$count = count($patharr)+2;
			$i = 2;
			while($i<$count){
				if(isset($patharr[$i+1])){
					$_GET[$patharr[$i]] = $patharr[$i+1]; 
				}
				$i = $i + 2;
			}
		} else {
			$this->ctrl = C('CTRL');
			$this->action = C('ACTION');
		}
	}
}